package org.pro.system.controller;

import javax.servlet.http.HttpServletRequest;

import org.pro.base.domain.SysUsers;
import org.pro.system.service.SysUsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.method.P;
import org.springframework.social.connect.web.ProviderSignInUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.ServletWebRequest;

@RestController
@RequestMapping("/sysUserController")
public class SysUsersController {

	@Autowired
	public SysUsersService sysUsersService;

	@Autowired
	public ProviderSignInUtils providerSignInUtils;
	
	@RequestMapping(value="/query",name="根据id查询用户")
	public SysUsers query(int id) {
		return sysUsersService.queryById(id);
	}
	
	/**
	 * 注册第三方用户，插入到 tb_UserConnection 表中
	 * @param sysUsers
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/register",name="注册用户")
	public void register(SysUsers sysUsers,HttpServletRequest request) {
		String userId = sysUsers.getId()+"";
		providerSignInUtils.doPostSignUp(userId, new ServletWebRequest(request));
		//return sysUsersService.save(sysUsers);
	}
}
